package com.wlyuan.index.domain.index.repository.old;

import com.wlyuan.core.domain.valueobj.TenantId;
import com.wlyuan.core.domain.valueobj.WaybillId;
import com.wlyuan.transport.constants.WaybillTypeEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 运单索引
 *
 * @author yuanjie
 */
@Data
@Document(indexName = "waybill_index")
@EqualsAndHashCode(exclude = {
        "indexId",
        "carrierContactMobile",
        "carrierContactName",
        "showPickCovenant",
        "trackInfo",
        "waybillType"
})
public class WaybillIndexOld implements Serializable {
    @Id
    @Field(index = false)
    private Long indexId;

    public WaybillIndexOld id(WaybillId waybillId, WaybillTypeEnum type, TenantId tenantId) {
        this.waybillId = waybillId.getId();
        this.waybillType = type.getValue();
        this.tenantId = tenantId.getId();
        this.indexId = new WaybillIndexId(waybillId, type, tenantId).getId();
        return this;
    }

    @ApiModelProperty("运单ID")
    private Long waybillId;

    @ApiModelProperty("合同号")
    @Field(type = FieldType.Keyword)
    private String contractNo;

    @ApiModelProperty("关联查询关键字")
    @Field(type = FieldType.Keyword)
    private List<String> relationKeyword;

    @ApiModelProperty("运单状态")
    private Integer status;

    @ApiModelProperty("设备类型0未绑定，1电子回单  2快递")
    private Integer trackType;

    @ApiModelProperty("设备编号/快递号")
    @Field(type = FieldType.Keyword)
    private String deviceCode;

    @ApiModelProperty("运输方式")
    private Integer shipMode;

    @ApiModelProperty("预计发货时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime fromTime;

    @ApiModelProperty("预计收货时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime toTime;

    @ApiModelProperty("创建时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime createAt;

    @ApiModelProperty("租户ID")
    private Long tenantId;

    @ApiModelProperty("发货联系人")
    @Field(type = FieldType.Keyword)
    private String fromContactName;

    @ApiModelProperty("发货方名称")
    @Field(type = FieldType.Keyword)
    private String customerName;

    @ApiModelProperty("发货省编码")
    @Field(type = FieldType.Keyword)
    private String fromProvinceCode;

    @ApiModelProperty("发货市编码")
    @Field(type = FieldType.Keyword)
    private String fromCityCode;

    @ApiModelProperty("发货市名称")
    @Field(type = FieldType.Keyword)
    private String fromCityName;

    @ApiModelProperty("发货区/县编码")
    @Field(type = FieldType.Keyword)
    private String fromDistrictCode;

    @ApiModelProperty("发货详细地址")
    @Field(type = FieldType.Keyword)
    private String fromAddress;

    @ApiModelProperty("收货方名称")
    @Field(type = FieldType.Keyword)
    private String consigneeName;

    @ApiModelProperty("收货省编码")
    @Field(type = FieldType.Keyword)
    private String toProvinceCode;

    @ApiModelProperty("收货市编码")
    @Field(type = FieldType.Keyword)
    private String toCityCode;

    @ApiModelProperty("收货市名称")
    @Field(type = FieldType.Keyword)
    private String toCityName;

    @ApiModelProperty("收货区/县编码")
    @Field(type = FieldType.Keyword)
    private String toDistrictCode;

    @ApiModelProperty("收货联系人")
    @Field(type = FieldType.Keyword)
    private String toContactName;

    @ApiModelProperty("收货详细地址")
    @Field(type = FieldType.Keyword)
    private String toAddress;

    @ApiModelProperty("是否保价")
    private Integer insure;

    @ApiModelProperty("是否提货")
    private Integer pick;

    @ApiModelProperty("是否送货")
    private Integer deliver;

    @ApiModelProperty("是否装货")
    private Integer onLoad;

    @ApiModelProperty("是否卸货")
    private Integer offLoad;

    @ApiModelProperty("签收时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime signAt;

    @ApiModelProperty("回单时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime receiptAt;

    @ApiModelProperty("签收类型")
    private Integer signType;

    @ApiModelProperty("运输模式")
    private Integer transportMode;

    @ApiModelProperty("承运方名称")
    @Field(type = FieldType.Keyword)
    private String carrierName;

    @ApiModelProperty("承运方联系人")
    @Field(type = FieldType.Keyword)
    private String carrierContactName;

    @ApiModelProperty("承运方联系电话")
    @Field(type = FieldType.Keyword)
    private String carrierContactMobile;

    @ApiModelProperty("总重量(含补差)")
    private BigDecimal calculateWeight;

    @ApiModelProperty("总体积(含补差)")
    private BigDecimal calculateVolume;

    @ApiModelProperty("总数量")
    private Integer totalQuantity;

    @ApiModelProperty("是否被合单 0:未被合单，1:被合单")
    private Integer combine;

    @ApiModelProperty(" 10：发货方运单,20：承运方运单")
    private Integer waybillType;


    @ApiModelProperty("关单状态 10撤回中, 20待审核, 30拒绝中,40拒绝,50关单中，60同意")
    private Integer closeStatus;

    @ApiModelProperty("签收异常状态 1是，0否")
    private Integer signExceptionStatus;

    @ApiModelProperty("上传回单照片状态 1是，0否")
    private Integer receiptAttachmentStatus;

    @ApiModelProperty("回单丢失状态 1是，0否")
    private Integer receiptLoseStatus;

    @ApiModelProperty("补单状态 1是，0否")
    private Integer receiptReplenishStatus;

    @ApiModelProperty("回单复核状态 1是，0否")
    private Integer receiptReviewStatus;

    @ApiModelProperty("报价状态")
    private Integer quotationStatus;

    @ApiModelProperty("已产生费用 0否，1是")
    private Integer feeGenerated;

    @ApiModelProperty("总费用")
    private BigDecimal totalFee;

    @ApiModelProperty("自营司机")
    @Field(type = FieldType.Keyword)
    private String driverName;

    @ApiModelProperty("是否可以提货预约 0：否，1：是")
    @Field(type = FieldType.Integer)
    private Integer showPickCovenant;

    @ApiModelProperty("提货预约状态 0：未确认，1：已确认")
    @Field(type = FieldType.Integer)
    private Integer pickCovenantStatus;

    @ApiModelProperty("进场时间")
    @Field(type = FieldType.Date, format = DateFormat.custom, pattern = {DateFormats.SIMPLE, DateFormats.NORMAL, DateFormats.FULL})
    private LocalDateTime arrivalTime;

    @ApiModelProperty("是否签收延迟")
    private Integer signDelayed;

    @ApiModelProperty("关单审核租户")
    private Long closeToTenantId;


    /*************todo 以下字段已经废弃*****************/
    @Deprecated
    @ApiModelProperty("0:预计提前到达，1:预计超时，2:已超时")
    private Integer delayStatus;

    @Deprecated
    @ApiModelProperty("离收货地距离(米)")
    private Integer distanceKm;

    @Deprecated
    @ApiModelProperty("离收货地距离(秒)")
    private Integer distanceTime;

    @Deprecated
    @ApiModelProperty("预警预报")
    @Field(type = FieldType.Keyword)
    private String trackInfo;

    @Deprecated
    @ApiModelProperty("运输状态 1提货中,2已发货,3已到达,4已签收")
    private Integer transportStatus;

}
